package com.flying.inherit.inheritanceTest3;

/**
 * @ClassName: Test3
 * @createDate: 2023/6/27 19:58
 * @author: liu
 * @description:练习3_子类重写了父类的set方法
 */
public class Test3 {
    public static void main(String[] args) {
        Father f=new Father();
        Son s=new Son();

        System.out.println(f.getInfo());  //  atguigu
        System.out.println(s.getInfo());  //  atguigu

        s.setInfo("尚硅谷");

        System.out.println(f.getInfo());   // atguigu
        System.out.println(s.getInfo());   // atguigu

    }
}

class Father{
    private String info="atguigu";
    public void setInfo(String info){
        this.info=info;
    }
    public String getInfo(){
        return info;
    }
}

class Son extends Father {
    private String info="大硅谷";
    @Override
    public void setInfo(String info) {
        this.info=info;
    }
}
